package com.example.auth.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.context.SecurityContextRepository;
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
import org.springframework.session.security.SpringSessionBackedSecurityContextRepository;

@Configuration
public class SecurityContextConfig {

    @Bean
    public SecurityContextRepository securityContextRepository(RedisIndexedSessionRepository sessionRepository) {
        SpringSessionBackedSecurityContextRepository repository = new SpringSessionBackedSecurityContextRepository();
        SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
        return repository;
    }
} 